<template>
  <div class="MOCVD">
    <div class="mocvd-c">
      <dynForm
        ref="dataForm"
        :is-inline="false"
        :info-form="infoForm"
        :search-tags="searchTags"
        :form-disable="disabled"
        :rules="rules"
      />
      <div class="mocvd-btn">
        <el-button :loading="loading" type="primary" @click="handlePPSelect">PP-Select</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { doPPSelect } from '@/api/production/webOUI'
export default {
  name: 'MOCVD',
  data() {
    return {
      infoForm: {},
      disabled: false,
      loading: false,
      searchTags: [{ label: this.$t('eqpName'), prop: 'eqpName', tag: 'DynInput' },
        { label: this.$t('LotNumebr'), prop: 'lotId', tag: 'DynInput' },
        { label: 'Recipe ID', prop: 'recipeId', tag: 'DynInput' }],
      rules: {
        eqpName: [
          { required: true, message: `${this.$t('pleaseInput')}${this.$t('eqpName')}`, trigger: 'blur' }
        ],
        lotId: [
          { required: true, message: `${this.$t('pleaseInput')}${this.$t('LotNumebr')}`, trigger: 'blur' }
        ],
        recipeId: [
          { required: true, message: `${this.$t('pleaseInput')}Recipe ID`, trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    handlePPSelect() {
      this.$refs['dataForm'].$refs['dynForm'].validate((valid) => {
        if (valid) {
          this.loading = true
          doPPSelect(this.$clearNull(this.infoForm)).then(res => {
            if (res.code === 1) {
              this.disabled = true
            } else {
              this.disabled = false
            }
            this.loading = false
            this.$betterTips(res)
          }).catch(() => {
            this.loading = false
            this.disabled = false
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.MOCVD{
    width: 100%;
    background-color: #fff;
    .mocvd-c{
        width: 600px;
        margin: 0 auto;
        padding: 22px 22px 22px 0;
        .mocvd-btn{
            width: 100%;
            text-align: right;
        }
    }
}
</style>
